package com.nacos.utils;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;

import java.util.Properties;

public class NacosConfigExample {

    public static void main(String[] args) throws NacosException {
        String serverAddr = "localhost:8848"; // Nacos 服务器地址
        String dataId = "configService-dev.yaml"; // 配置文件的dataId
        String group = "DEFAULT_GROUP"; // 配置文件的group

        Properties properties = new Properties();
        properties.put("serverAddr", serverAddr);
        properties.put("namespace", "229bd3af-0083-495a-a44c-774b2e45c7f1");
        ConfigService configService = NacosFactory.createConfigService(properties);

        String content = configService.getConfig(dataId, group, 5000);
        System.out.println(content);
    }
}